// 封装所有请求操作
import axios from '../../index'
import qs from 'qs'


// let api = 'http://192.168.221.217:8080'

// 跟单列表
export const gendanListAxios = (parmas) => {
    console.log(parmas);
    return axios({
        url: '/documentary/findDocumentaryList',
        method: 'POST',
        data: {
            currentPage: parmas.currentPage || 1, // 页数
            pageSize: parmas.pageSize || 3, // 一页的数据总量
            data: {
                employee_name: parmas.employee_name,
                need_starttime: parmas.need_starttime ? parmas.need_starttime : '',
                need_stoptime: parmas.need_stoptime ? parmas.need_stoptime : '',
                already_starttime: parmas.already_starttime ? parmas.already_starttime : '',
                already_stoptime: parmas.already_stoptime ? parmas.already_stoptime : '',
            },
        }
    })
}

// 跟单删除
export const gendanDeleteAxios = (parmas) => {
    console.log(parmas);
    return axios({
        url: '/documentary/deleteDocumentary',
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: qs.stringify({
            documentary_deletereason: parmas.deletereason, // 删除原因
            documentary_id: parmas.id // 删除 id
        })
    })
}

// 跟单附件上传
export const gendanAddFileAxios = (arr) => {
    console.log(arr);
    return axios({
        url: '/document/saveDocument',
        method: 'POST',
        data: arr
    })
}

// 跟单修改
export const gendanUpdateAxios = (parmas) => {
    console.log(parmas);
    return axios({
        url: '/documentary/updateDocumentary',
        method: 'POST',
        data: {
            documentary_id: parmas.documentary_id,
            contact_id: parmas.contact_id, // 跟单对象 id  
            customer_id: parmas.customer_id,
            employee_name: parmas.employee_name,
            // documentary_end: parmas.documentary_end, // 是否结束跟单 0 不结束
            documentary_nextcontacttime: parmas.documentary_nextcontacttime, // 下次联系时间
            documentary_remark: parmas.documentary_remark, // 备注
            documentary_remind: parmas.documentary_remind, // 是否结束跟单
            documentary_status: parmas.documentary_status, // 跟单状态
            documentary_remindtime: parmas.documentary_remindtime, // 提醒时间 + ':00.0'
            documentary_type: parmas.documentary_type // 跟单方式
        }
    })
}

// 跟单新增
export const gendanAddAxios = (parmas) => {
    console.log(parmas);
    return axios({
        url: '/documentary/addDocumentary',
        method: 'POST',
        data: {
            contact_id: parmas.contact_id, // 跟单对象 id  parmas.region3
            customer_id: parmas.customer_id, // 客户 id
            employee_name: parmas.employee_name,
            documentary_end: parmas.documentary_end, // 是否结束跟单 0 不结束
            documentary_nextcontacttime: parmas.documentary_nextcontacttime, // 下次联系时间
            documentary_remark: parmas.documentary_remark, // 备注
            documentary_remind: parmas.documentary_remind, // 是否提示 0不提示
            documentary_status: parmas.documentary_status, // 跟单状态
            documentary_remindtime: parmas.documentary_remindtime, // 提醒时间 + ':00.0'
            documentary_type: parmas.documentary_type // 跟单方式
        }
    })
}

// 简单查询
export const gendanEasySearchAxios = (parmas) => {
    console.log(parmas);
    return axios({
        url: '/documentary/searchDocumentaryList',
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        method: 'POST',
        data: qs.stringify({
            condition: parmas.condition, // 搜索值
            pageSize: parmas.pageSize,
            currentPage: parmas.currentPage,
            employee_name: parmas.employee_name
        })
    })
}

// 高级搜索
export const gendanHighSearchAxios = (parmas) => {
    console.log(parmas);
    return axios({
        url: '/documentary/searchDocumentaryListByCondition',
        method: 'POST',
        data: {
            pageSize: parmas.pageSize,
            currentPage: parmas.currentPage,
            data: {
                employee_name: parmas.employee_name,
                documentary_type: parmas.documentary_type,
                already_starttime: parmas.already_starttime,
                already_stoptime: parmas.already_starttime,
                need_starttime: parmas.need_starttime,
                need_stoptime: parmas.need_stoptime,
                documentary_remark: parmas.documentary_remark,
                customer_id: parmas.customer_id,
                customer_name: parmas.customer_name,
                contact_name: parmas.contact_name,
                documentary_status: parmas.documentary_status
            },
        }
    })
}

// 附件查询
export const gendanFileFindAxios = (documentary_id) => {
    console.log(documentary_id);
    return axios({
        url: '/document/queryDocument',
        method: 'POST',
        data: qs.stringify({
            documentary_id
        })
    })
}

// 附件删除
export const gendanFileDeleteAxios = (document_id) => {
    console.log(document_id);
    return axios({
        url: '/document/deleteDocument',
        method: 'POST',
        data: qs.stringify({
            document_id
        })
    })
}

// 跟单人查询
export const gendanPersonAxios = () => {
    return axios({
        url: '/afterSales/queryEmp',
        method: 'POST'
    })
}